Program to read the columns list from a Table
import java.sql.*;
public class Sample
{
public static void main(String args[])
{
Connection con=null;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:vision","scott","tiger");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery(“select * from emp”);
ResultSetMetaData rsmd=rs.getMetaData();
int c =rsmd.getColumnCount();
for(int i=1;i<=c;i++)
{
String na=rsmd.getColumnName(i);
System.out.println(na);
}
}
catch(ClassNotFoundException e)
{
e.printStackTrace();
}
catch(SQLException e)
{
e.printStackTrace();
}
finally
{
try
{
if(con!=null)
con.close();
}
catch(SQLException e)
{
e.printStackTrace();
}
}
}
}